<?php
/**
 * @file designindexcontroller.php $
 * @author LinLin (linlin@haibao.com) $
 * @date 2015-12-9 下午6:43:15 $
 * @brief  $
 */
namespace haibao\cms\business\control\pc\channel\design;

use haibao\cms\business\Designer as DesignerBusiness;
use haibao\cms\business\Brand as BrandBusiness;

class DesignIndexController extends DesignController{
	public function __construct($updateTime = null,$controlId= '',$isPublish=''){
		parent::__construct($updateTime,$controlId,$isPublish);
	}
	
	public function displayTemplateHtml(){
		$controlData = $this->getParameter(self::$CONTROL_DATA);
		$content = $this->getParameter(self::$CONTROL_CONTENT);
		$path = $this->generateHtmlPath(__CLASS__);
		
		$this->baseUrl = \haibao\classlibrary\Config::getConfig(\haibao\classlibrary\Config::CLASSLIBRARY_CONFIG_HOST_DESIGNER).'/designer/list/';
		$searchDesignerUrl = $this->baseUrl.'0-0-0-0-0-0-0/';
		$desigerType = \haibao\www\model\data\Favorite::ATTENTION_TYPE_DESIGNER;
		
		//现设计师动态
		if($controlData['manual'] && $controlData['manual']['contorllerType'] == 'DesignerTrends'){
		    $designerMajor = array();
    		$data = self::getDesignInstance();
    		$designerMajor = $data->getBigDesign();
    		$this->assign('designerMajor', $designerMajor);
		}
		
		//现 大牌设计师 + 检索入口
		if($controlData['manual'] && $controlData['manual']['contorllerType'] == 'MajorDesigner'){
		    $designerLetterList = array();
		    //字母检索入口
		    $brandsIdArr = $designerImgIds = $brandsTadIds = $designerIdArr = array();
		    for($start=ord("A");$start<=ord("Z");$start++){
		        $temp['name'] = chr($start);
		        $temp['url'] = $this->baseUrl.'0-0-0-0-0-'.$temp['name'].'-0/';
		        array_push($designerLetterList,$temp);
		    }
		    array_push($designerLetterList,array('name'=>'其他','url'=>$this->baseUrl.'0-0-0-0-0-OTHER-0/'));
		
		    $parameters = $handWorship = $automaticWorship = array();
		    //大牌设计师   下面的本周推荐设计师 10个
		    $data = self::getDesignInstance();
		    $designersId = $data->getDesignerIds();
		    $designerWorship = $data->getDesignerByAttention($designersId,'',$controlData['manual']['limit']);
		    if($designerWorship){
		        foreach($designerWorship as $key=>$val){
		            $designerImgIds[$val->TagId] = $val->ImgId;
		        }
		        $designerImagesUrl = \haibao\cms\business\ImageLibrary::getImageUrlById($designerImgIds);
		        
		        $designerWor = array();
		        foreach($designerWorship as $key=>$val){
		            $val->ImageUrl = self::getImageLink($val->ImgId,160,160);
		            $val->DesignUrl = \haibao\classlibrary\Config::getConfig(\haibao\classlibrary\Config::CLASSLIBRARY_CONFIG_HOST_DESIGNER).'/designer/'.$val->TopicId.'/';
		            if(isset($designerImagesUrl[$val->ImgId])){
		                $val->ImageUrl = $designerImagesUrl[$val->ImgId];
		            }
		        }
		        $this->assign('designerWorship', $designerWorship);
		    }
		   
		    $this->assign('designerLetterList', $designerLetterList);//检索入口 */
		    
		    //设计师私照
		    $designerTrends = array();
		    $data = self::getDesignInstance();
		    $designerTrends = $data->getDesignDynamic();
		    $this->assign('designerTrends', $designerTrends);
		}
		
		
		
		
		$this->assign('searchDesignerUrl', $searchDesignerUrl);
		$this->assign('desigerType', $desigerType);
		$this->assign('brandPath', \haibao\classlibrary\www\Config::getConfig(\haibao\classlibrary\www\Config::CLASSLIBRARY_CONFIG_HOST_BRAND).'/brand/2848/' );
		$this->assign('ethnicPath', \haibao\classlibrary\www\Config::getConfig(\haibao\classlibrary\www\Config::CLASSLIBRARY_CONFIG_HOST_BRAND).'/brand/7620/' );
		$this->assign('chinaPath', \haibao\classlibrary\www\Config::getConfig(\haibao\classlibrary\www\Config::CLASSLIBRARY_CONFIG_HOST_BRAND).'/brand/7845/' );
		
		$isNewHtml = $this->generateHtml($path,$content);
		$content = $this->getHtml($path);
		$content = $this->replaceCDNLink($content);
		return $content;
	}
}